#ifndef MAINWINDOW2_H
#define MAINWINDOW2_H

#include <opencv2/opencv.hpp>
#include <opencv2/videoio/videoio.hpp>
#include <QPaintEvent>
#include <QTimer>
#include <QPainter>
#include <QPixmap>
#include <QLabel>
#include <QImage>
#include <QTimer>
#include <QMainWindow>
#include <QThread>
#include <QDateTime>
#include <string>

#include "face.h"
#include "camerawork.h"
#include "facework.h"
#include "sqlitehelper.h"
#include "noticewidget.h"

namespace Ui {
class MainWindow2;
}

class MainWindow2 : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow2(QWidget *parent = 0);
    ~MainWindow2();
    void InitNet();
    QString matToQstring(ncnn::Mat& m);

public slots:
    void setZhixinValue();
    void setZhixinSliderValue();


    void reciveFacename(QString);
    void reciveFace(cv::Mat);
    void reciveFeat(ncnn::Mat);//特征保存
    void updateImage();
    void updateImage2();


private slots:
    void on_btnOpenCam_clicked();

    void on_btnCloseCam_clicked();

    void on_fileselect_clicked();

    void on_btnOpenCam_2_clicked();

    void on_btnCloseCam_2_clicked();

    void on_btnStartCapture_2_clicked();

    void on_pushfile_clicked();

    void alertShow(QString);

    void on_tabWidget_currentChanged(int index);

    void on_deletefacedata_clicked();

    void on_notflagbtn_clicked();

    void on_allflagbtn_clicked();

    void on_okflagbtn_clicked();

    void on_updatefacedata_clicked();


    void on_lookpic_clicked();

private:
    Ui::MainWindow2 *ui;

    cv::VideoCapture capture;
    QTimer theTimer;
    QTimer theTimer2;
    QTimer theTimer3;

    QString today =QString("log")+QDateTime::currentDateTime().toString("yyyyMMdd");

    cv::Mat srcImage;
    cv::Mat image_fliped;
    int index = 0;
    cv::Mat faceimage;

    ncnn::Net facedistinnet;
    int faceflag=0;
    QString sourceface;//比对人脸路径

    QThread *firstThread;//线程1 视频捕获
    Camerawork *myCamThread;

    QThread *secondThread;
    Facework *faceThread;//线程2 识别+存储

    QThread *thirdThread;//线程3 视频捕获2 拍照
    Camerawork *myCamThread2;
    ncnn::Mat facefeat;
    SQLiteHelper helper = SQLiteHelper(QString("people.db"),QString("face"));//人脸数据库

    QString imagepath;

};

#endif // MAINWINDOW2_H
